package iserver

import (
	"src/zeus/threads"
)

type IDelayCallHandle interface {
	CallDelay(func()) error
	CallDelayExec()
	CallDelayExec2()
	// GetDelayCallChan() <-chan ICallInfo
	OnDestroyCallDelayHandle()
	Len() int
	ClearAllData()
}

type IDelayCallHost interface {
	CallDelay(func()) error
	// 加上等待
	CallDelayWait(cb func()) error
	SetDelayCallHandle(IDelayCallHandle)
	GetDelayCallHandle() IDelayCallHandle
	ClearAllData()
}

// type INoDelayCallHost interface {
// 	CreateNoDelayCallChan() chan bool
// 	GetNoDelayCallChan() chan bool
// }

type ICallInfo interface {
	Exec()
}

// IEntities 用于实体的管理
type IEntities interface {
	//msghandler.IMsgHandlers
	// events.IEvents

	CreateEntityAll(entityType string, dbid uint64, initParam interface{}, syncInit bool) (IEntity, error)
	DestroyEntityAll(entityID uint64) error

	CreateEntity(entityType string, entityID uint64, dbid uint64, spaceID uint64, initParam interface{}, syncInit bool, fly bool) (IEntity, error)

	DestroyEntity(entityID uint64) error
	DestroyEntityByDBID(entityType string, dbID uint64) error

	GetEntity(entityID uint64) IEntity
	GetEntityByDBID(entityType string, dbid uint64) IEntity

	TravsalEntity(entityType string, f func(IEntity))

	TravsalEntityByGroup(entityGroup string, f func(IEntity))

	EntityCount() int32

	MigrateEntity(entityID uint64, tarType uint8, tarSrvID uint64, tarSpaceID uint64) (bool, error)
	AddNeedRegType(srvType uint8)
	GetTypeIsInRegMap(srvType uint8) bool
	//在指定的服务器类型上创建ntt副本
	CreateEntityByServerType(srvType uint8, e IEntity) (result bool, err error)

	//注册entityGroup
	RegEntityGroup(group string, e IEntity)
	// UnRegEntityGroup  注销entityGroup
	UnRegEntityGroup(group string, e IEntity)

	GetMsgHandler() IMsgHandler

	IDelayCallHost

	GetThreadGo() *threads.ThreadGo
}
